package com.liuguang.framework.utils;

import android.annotation.SuppressLint;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

public class ToastUtils {
    private static boolean isShow = true;
    private static Toast sToast;

    public static void toast(String str) {
        Toast.makeText(AppUtils.getApplication(), str, Toast.LENGTH_SHORT).show();
    }

    @SuppressLint("WrongConstant")
    public static void show(String str) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication().getApplicationContext(), str, Toast.LENGTH_SHORT);
            sToast.show();
        }
    }

    public static void showShort(int i) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication(), i, Toast.LENGTH_SHORT);
            sToast.show();
        }
    }

    public static void showShort(String str) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication(), str, Toast.LENGTH_SHORT);
            sToast.show();
        }
    }

    public static void showLong(int i) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication(), i, Toast.LENGTH_SHORT);
            sToast.show();
        }
    }

    public static void showLong(String str) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication(), str, Toast.LENGTH_SHORT);
            sToast.show();
        }
    }

    public static void show(int i, int i2) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication(), i, i2);
            sToast.show();
        }
    }

    public static void show(String str, int i) {
        if (isShow) {
            if (sToast != null) {
                sToast.cancel();
                sToast = null;
            }
            sToast = Toast.makeText(AppUtils.getApplication(), str, i);
            sToast.show();
        }
    }

    public static void showImageAndText(int i, int i2) {
        showImageAndText(i, AppUtils.getApplication().getResources().getString(i2), 0, 17);
    }

    public static void showImageAndText(int i, CharSequence charSequence) {
        showImageAndText(i, charSequence, 0, 17);
    }

    public static void showImageAndText(int i, CharSequence charSequence, int i2, int i3) {
        Toast makeText = Toast.makeText(AppUtils.getApplication(), charSequence, i2);
        makeText.setGravity(i3, 0, 0);
        LinearLayout linearLayout = (LinearLayout) makeText.getView();
        ImageView imageView = new ImageView(AppUtils.getApplication());
        imageView.setImageResource(i);
        linearLayout.addView(imageView, 0);
        makeText.show();
    }
}
